/*
 * @Author: Y先森
 * @Date: 2023-05-02 17:42:46
 * @LastEditors: y && 250048395@qq.com
 * @LastEditTime: 2023-05-02 17:43:06
 * @FilePath: \y-website\src\Project\yyds\router\index.js
 */
import { createRouter, createWebHashHistory } from 'vue-router'
const router = createRouter({
  history: createWebHashHistory(), // hash模式：createWebHashHistory，history模式：createWebHistory
  routes: [
    {
      path: '/home',
      name: 'index',
      component: () => import('@Project/yyds/views/index.vue'),
      meta: { title: '首页' }
    }
  ]
})

router.afterEach((to, from, next) => {
  //遍历meta改变title
  if (to.meta.title) {
    document.title = to.meta.title
  }
  window.scrollTo(0, 0)
})
export default router
